#ifndef bailian_MyAStar_h
#define bailian_MyAStar_h

#include "../PreInclude.h"
#include "../utils/Utils.h"



struct  AStarNode {
    
    int x;
    int y;
    int type;
    int inList;
    AStarNode* parentNode;
    int g;
    int h;
    int f;
    
    AStarNode(){
        
    }
    
    AStarNode(int nX,int nY,int nType){
        x = nX;
        y = nY;
        type = nType;
        reset();
    }
    
    
    void reset(){
        inList = 0;
        parentNode = NULL;
        g = 0;
        h = 0;
        f = 0;
    }
    
};

class MyAStar{
public:
    
    void wayfinding(CCPoint& startPos, CCPoint& endPos,vector<CCPoint>& ret, bool isEight=true);
    
    AStarNode* getMinFNode();
    
    void Init(int* , int w,int h);
    
    void quitList(AStarNode* node);
   
    void nodeLogic(AStarNode* node1, AStarNode* node2 , int value);
    
    void getAroundNode(AStarNode* node, bool isEight);
    
    void reset();
    
    void cleanUp();
    
    int getBlock(int nX,int nY);
    
    bool isBlock(int nX,int nY);
protected:
    int row ;
    
    int col;
    
    AStarNode* startNode;
    
    AStarNode* endNode;
    
    AStarNode* nowNode;
     
    
    vector<vector<AStarNode> >  astarMapArr;
    
    std::list<AStarNode*>  openList;
    
    std::list<AStarNode*> closeList;
     
     
};

#endif
